/**
 * Created by baiguiren on 1/23/17.
 */

let async = require('async');

async.race([
  function (callback) {
    setTimeout(function () {
      callback(null, 'one');
    }, 200);
  },
  function (callback) {
    setTimeout(function () {
      callback(null, 'two');
    }, 100);
  }
],
// main callback
  function (err, result) {
    // the result will be equal to 'two' as it finishes earlier
    console.log(result);
  }
);